#include "SplashState.h"

SplashState::SplashState()
{

}

void SplashState::Load()
{
    fundo = IMG_Load("splashfundo.png");
    logo = IMG_Load("logo.png");

    text = new Text("liberation_sans.ttf","L Mouse Button to Continue", 150, 640, TTF_STYLE_NORMAL, 0, 0, 0, 32);
    text2 = new Text("liberation_sans.ttf","Esc to Quit", 150, 672, TTF_STYLE_BOLD, 0, 0, 0, 30);

    //music = new Audio("", 1);
    //music->PlayMusic(-1);

    time = new TimeCounter();
    time->Start();

    dstrect.x = 0;
    dstrect.y = 0;
}

void SplashState::Unload()
{
    //time->Stop();
    delete(text);
    delete(text2);
    //music->Stop();
    //delete(music);
    //SDL_FreeSurface(fundo);
    //SDL_FreeSurface(logo);
}

int SplashState::Update(int dt)
{
    //printf("\nSPLASH STATE - TIME COUNTER = %d\n",time->GetTime());

    InputManager *inmanager;
    inmanager = InputManager::getInstance();

    quit = inmanager->Update();
    if(inmanager->isMouseDown(1))
        return 2;

    if(inmanager->isKeyPressed(SDLK_ESCAPE) || quit)
        return -1;


    return 0;
}

void SplashState::Render(SDL_Surface *screen)
{
    SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));
    SDL_BlitSurface(fundo, 0, screen, &dstrect);
    SDL_BlitSurface(logo, 0, screen, &dstrect);


    text->Render(screen);
    text2->Render(screen);


}
